#if !defined(ximera_math_vector2_hpp)
#define ximera_math_vector2_hpp

// -----------------------------------------------------------

#include <ximera/types.hpp>
#include <ximera/math/util.hpp>

namespace ximera { namespace math
{
    class XIMERA_API Vector2
    {
    public:
        Real x, y;

    public:
        Vector2();
        Vector2(Real x, Real y);
        explicit Vector2(Real xy);
        explicit Vector2(Real const xy[2]);

        Real length() const;
        Real lengthSquared() const;
        
        Vector2& normalize();
        Vector2 asNormal() const;

        Real dotProduct(Vector2 const& vec) const;

        Real& operator[](int i);
        Real const& operator[](int i) const;

        Real* array();
        Real const* array() const;

        Vector2 operator-() const;

        Vector2& operator+=(Vector2 const& rhs);
        Vector2& operator-=(Vector2 const& rhs);
        Vector2& operator*=(Real rhs);
        Vector2& operator/=(Real rhs);

        static Vector2 const ZERO;
        static Vector2 const E1;
        static Vector2 const E2;
    };

    // Vector2-Vector2 arithmetic
    Vector2 operator-(Vector2 const& lhs, Vector2 const& rhs);
    Vector2 operator+(Vector2 const& lhs, Vector2 const& rhs);
    Real operator*(Vector2 const& lhs, Vector2 const& rhs);

    // Vector2-Real arithmetic
    Vector2 operator*(Vector2 const& lhs, Real rhs);
    Vector2 operator*(Real lhs, Vector2 const& rhs);
    Vector2 operator/(Vector2 const& lhs, Real rhs);

    // Comparisons
    bool operator==(Vector2 const& lhs, Vector2 const& rhs);
    bool operator!=(Vector2 const& lhs, Vector2 const& rhs);
    bool operator<(Vector2 const& lhs, Vector2 const& rhs);
    bool operator>(Vector2 const& lhs, Vector2 const& rhs);
}}

#include <ximera/math/inline/vector2.inl>

// -----------------------------------------------------------

#endif
